package io.renren.modules.simida.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.simida.entity.UserCertEntity;
import io.renren.modules.simida.service.UserCertService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 用户认证表
 *
 * @author miaoguoxin
 * @email ${email}
 * @date 2019-12-01 13:39:55
 */
@RestController
@RequestMapping("simida/usercert")
public class UserCertController {
    @Autowired
    private UserCertService userCertService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("simida:usercert:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = userCertService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("simida:usercert:info")
    public R info(@PathVariable("id") Long id){
		UserCertEntity userCert = userCertService.getById(id);

        return R.ok().put("userCert", userCert);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("simida:usercert:save")
    public R save(@RequestBody UserCertEntity userCert){
		userCertService.save(userCert);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("simida:usercert:update")
    public R update(@RequestBody UserCertEntity userCert){
		userCertService.updateById(userCert);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("simida:usercert:delete")
    public R delete(@RequestBody Long[] ids){
		userCertService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
